IF LASTKEY()=27
   CLOS ALL
   RETURN
ENDIF
nvisit=nvisit+1
@ 16,70 say nvisit pict "999,999"
TTL=TTL+TOTAL_FEE
TPA=TPA+TOTAL_PAY
THL=THL+TOTAL_HL
TMS=TMS+TOTAL_MS
TCP=TCP+TOTAL_CASH
TCR=TCR+TOTAL_CRED
IF TOTAL_FEE>TOTAL_PAY+TOTAL_HL
   IF PAT_CODTYP='9' .OR. PAT_CODTYP='0'
      TFE=TFE+(TOTAL_FEE-(TOTAL_PAY+TOTAL_HL))
    ELSE
     TFC=TFC+(TOTAL_FEE-(TOTAL_PAY+TOTAL_HL))
   ENDIF
ENDIF
IF TOTAL_CASH<>0
   DO CASE
      CASE PAY_MODE='CASH'
         TCA=TCA+TOTAL_CASH
      CASE PAY_MODE='CARD'
         TCC=TCC+TOTAL_CASH
      CASE PAY_MODE='CHEQUE'
         TCH=TCH+TOTAL_CASH
      OTHER
         TCA=TCA+TOTAL_CASH
   ENDCASE
ENDIF
skip
